package com.rsscollector.util;

import org.apache.log4j.Logger;
import com.rsscollector.feedrss.parser.GenericParser;

import java.util.HashMap;
import java.util.Properties;
import java.util.Enumeration;
import java.util.Collections;
import java.io.InputStream;
import java.io.IOException;

/**
 * Created by IntelliJ IDEA.
 * User: Vu Nga
 * Date: Jan 28, 2007
 * Time: 12:15:24 PM
 * To change this template use File | Settings | File Templates.
 */
public class SystemUtils {
    private static Logger logger = Logger.getLogger(SystemUtils.class.getName());
    private static String RSSCOLLECTOR_CONFIG = "/rsscollector_config.properties";
    private static Properties properties = null;

    public static String URL_RSSCOLLECTOR = "URL_RSSCOLLECTOR";
    public static String get (String key) {
        String result = null;
        if (properties == null) {
            try {
                // Read properties file.
                ClassLoader cl = SystemUtils.class.getClassLoader();
                InputStream is = cl.getResourceAsStream(RSSCOLLECTOR_CONFIG);
                properties = new Properties();
                properties.load(is);
                is.close();
                result = properties.getProperty(key);
            } catch (IOException e) {
                logger.error("Error when initializing ParserFactory", e);
            }
        }
        else {
             result = properties.getProperty(key);
             result = properties.getProperty(key);
        }
        return result;
    }
}
